<?php

namespace App\Models\Kms;

use App\Models\BaseModel;

class KmsIosCode extends BaseModel
{

    protected $table = "kms_ios_code";

    public $timestamps = false;


    const STATUS_NOT_USE = 0;
    const STATUS_USE     = 1;

    const STATUS_MAP_TEXT = [
        self::STATUS_NOT_USE => "未使用",
        self::STATUS_USE     => "使用"
    ];


    //redis-key
    const KMS_IOS_DOWNLOAD_CODE = 'KmsIosDownloadCode';

    public static function info(string $code = '')
    {
        return self::query()
            ->when(
                strlen($code), function ($query) use ($code) {
                $query->where('code', $code);
            }
            )
            ->where('status', KmsIosCode::STATUS_NOT_USE)
            ->first();
    }
}
